mod walker;

use ggez::{Context, GameResult, GameError, graphics};
use ggez::mint::Point2;

pub struct State{
    walker: walker::Walker,
}

impl State{
    pub fn new() -> State {
        State{walker : walker::Walker::new()}
    }
}

impl ggez::event::EventHandler<GameError> for State {
    fn update(&mut self, _ctx: &mut Context) -> GameResult {
        self.walker.step();
        Ok(())
    }
    fn draw(&mut self, ctx: &mut Context) -> GameResult {
        let mut canvas = graphics::Canvas::from_frame(ctx, graphics::Color::WHITE);
        let location: Point2<f32> = Point2 {x: self.walker.get_location().x, y: self.walker.get_location().y};
        let circle = graphics::Mesh::new_circle(
            ctx,
            graphics::DrawMode::fill(),
            location,
            16.0,
            0.1,
            graphics::Color::BLACK,
        )?;
        canvas.draw(&circle, graphics::DrawParam::default());
        
        canvas.finish(ctx)?;
        Ok(())
    }
}